/**
 * 
 */
package com.mvc.controller.notice;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.mvc.controller.base.BaseController;
import com.mvc.model.notice.Tnotice;
import com.mvc.service.notice.NoticeServiceI;

/**
 * 公告栏处理控制器
 * @author qingjie
 * date:2015-10-12
 *
 */
@Controller
@RequestMapping("/notice")
public class NoticeController extends BaseController {

	@Autowired
	private NoticeServiceI noticeServiceI;
	
	/**
	 * 点击更多
	 * @return
	 */
	@RequestMapping("/more")
	public String noticeMore(){
		return "web/notice/allNotice";
	}
	
	/**
	 * 显示所有公告
	 * @return
	 */
	@RequestMapping("/all")
	@ResponseBody
	public List<Object> getAll(){
		return noticeServiceI.getAllNotice();
	}
	
	/**
	 * 根据id获取单个公告
	 * @param mav
	 * @param id
	 * @return
	 */
	@RequestMapping("/{id}")
	public ModelAndView getNotice(ModelAndView mav,@PathVariable Long id){
		Tnotice tnotice = new Tnotice();
		tnotice.setId(id);
		mav.addObject("notice",noticeServiceI.getNoticeById(tnotice));
		mav.setViewName("web/notice/notice");
		return mav;
	}
}
